package pms.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	static public String toYYYYMMDD(Date dt) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(dt);
	}
	
	static public Date YYYYMMDDtoDate(String dt) {
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			return sdf.parse(dt);
		} catch (Exception ex) {
			return null;
		}
	}
	
	static public String getCurrentTimestamp() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS");
		return sdf.format(new Date());
	}
	
	static public String getCurrentTimestampCompact() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmssSSS");
		return sdf.format(new Date());
	}
	
	static public String getCurrentDate() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(new Date());
	}
}
